﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_DSJCJ.BLL
{
    public partial class SysBasicCodeCls
    {
        private readonly ElingOA6_DSJCJ.DAL.SysBasicCodeCls dal = new ElingOA6_DSJCJ.DAL.SysBasicCodeCls();
        public SysBasicCodeCls()
        { }
        #region  Method
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(string FCodeClsNo)
        {
            return dal.Exists(FCodeClsNo);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(ElingOA6_DSJCJ.Model.SysBasicCodeCls model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ElingOA6_DSJCJ.Model.SysBasicCodeCls model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(string FCodeClsNo)
        {

            return dal.Delete(FCodeClsNo);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string FCodeClsNolist)
        {
            return dal.DeleteList(FCodeClsNolist);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ElingOA6_DSJCJ.Model.SysBasicCodeCls GetModel(string FCodeClsNo)
        {

            return dal.GetModel(FCodeClsNo);
        }


        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }
        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return dal.GetList(Top, strWhere, filedOrder);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_DSJCJ.Model.SysBasicCodeCls> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_DSJCJ.Model.SysBasicCodeCls> DataTableToList(DataTable dt)
        {
            List<ElingOA6_DSJCJ.Model.SysBasicCodeCls> modelList = new List<ElingOA6_DSJCJ.Model.SysBasicCodeCls>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_DSJCJ.Model.SysBasicCodeCls model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ElingOA6_DSJCJ.Model.SysBasicCodeCls();
                    model.FCodeClsNo = dt.Rows[n]["FCodeClsNo"].ToString();
                    if (null != dt.Rows[n]["FParentCodeClsNo"] && dt.Rows[n]["FParentCodeClsNo"].ToString() != "")
                    {
                        model.FParentCodeClsNo = dt.Rows[n]["FParentCodeClsNo"].ToString();
                    }
                    model.FCodeClsName = dt.Rows[n]["FCodeClsName"].ToString();
                    model.FSpecURL = dt.Rows[n]["FSpecURL"].ToString();
                    model.FFiledName = dt.Rows[n]["FFiledName"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }

        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        //public DataSet GetList(int PageSize,int PageIndex,string strWhere)
        //{
        //return dal.GetList(PageSize,PageIndex,strWhere);
        //}

        #endregion  Method


        #region 增加的方法

        /// <summary>
        /// 获取编码类型名称
        /// <creator>rend</creator>
        /// <date>2012-11-12</date>
        /// </summary>
        /// <param name="codeClsNo"></param>
        /// <returns></returns>
        public string GetCodeClsName(string codeClsNo)
        {
            return dal.GetCodeClsName(codeClsNo);
        }

        #endregion

    }
}
